﻿using System;
using System.Web.UI.WebControls;
using Altairis.MailToolkit;

namespace SampleListManager {
    public partial class Send : System.Web.UI.Page {

        protected void Page_Load(object sender, EventArgs e) {
            // Populate dropdown with mailing list names
            if (!this.IsPostBack) {
                foreach (MailingListProvider list in MailingListManager.Lists) {
                    this.ListName.Items.Add(new ListItem(string.Format("{0} ({1} members)", list.Description, list.GetMemberCount()), list.Name));
                }
            }
        }

        protected void ButtonSubmit_Click(object sender, EventArgs e) {
            if (!this.IsValid) return;

            MailingListManager.SendMessages(this.ListName.SelectedValue, this.SubjectTextBox.Text, this.BodyTextBox.Text);
            this.MultiViewPage.SetActiveView(this.ViewMessage);
        }

    }
}